package dtaskboard.client.util;

import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.user.client.ui.Button;

public class EnterListener implements KeyDownHandler {

  private final Button toClick;

  public EnterListener(Button b) {
    this.toClick = b;
  }

  @Override
  public void onKeyDown(KeyDownEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
      this.toClick.click();
    }
  }

}
